import React from 'react'
import { useEffect } from 'react';
import { useState } from 'react'
import { store } from './index';

export default function ReduxTest() {

    const [count, setCount] = useState(1);
    const [ age, setAge] = useState(36);

    useEffect(() => {
        store.subscribe(() => {
            let cur = store.getState();
            setCount(() => cur.counter.count);
            setAge(() => cur.info.age)
        })
    })

  return (
    <div>
        <h5>count is {count}, age is {age}</h5>
        <button onClick={() => store.dispatch({ type: "ADD_COUNT"})}>ADD_COUNT</button>
    </div>
  )
}
